package org.sciom

class ScIomCompiler(state: ScIomState) extends ScIomObject(state) {
  var methodTable = List(
    ("tokensForString", (self: ScIomObject, locals: ScIomObject, m: ScIomMessage) => {
      if(self.isInstanceOf[ScIomCompiler]) {
        self.asInstanceOf[ScIomCompiler].tokensForString(locals, m)
      } else {
        null //TODO ERROR HERE
      }
    }),
    ("messageForString", (self: ScIomObject, locals: ScIomObject, m: ScIomMessage) => {
      if(self.isInstanceOf[ScIomCompiler]) {
        self.asInstanceOf[ScIomCompiler].messageForString(locals, m)
      } else {
        null //TODO ERROR HERE
      }
    }),
    ("messageForString2", (self: ScIomObject, locals: ScIomObject, m: ScIomMessage) => {
      if(self.isInstanceOf[ScIomCompiler]) {
        self.asInstanceOf[ScIomCompiler].messageForString2(locals, m)
      } else {
        null //TODO ERROR HERE
      }
    })
  )

  setSlotTo(state.symbolWithString("type"), state.symbolWithString("Compiler"))
  addMethodTable(methodTable)

  def tokensForString(locals: ScIomObject, m: ScIomMessage) : ScIomObject = null
  def messageForString(locals: ScIomObject, m: ScIomMessage) : ScIomObject = {
    var string = m.localsAndSeqArgAt(locals, 0)
    var result = state.ioNil
    
    println("message for string with m: " + m)

    ScIomMessage.newFromText(state, string)
  }

  def messageForString2(locals: ScIomObject, m: ScIomMessage) : ScIomObject = null
}
